home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cstdio.arc
/
SRC.ARC
/
MOVE.A
< prev
next >
Wrap
Text File
|
1984-12-27
|
888b
|
46 lines
; move.a - intrasegment move.
; (C) Copyright 1984 Cray Research Inc. - All Rights Reserved.
; G. R. Mansfield. 84/12/26.
; Ver 1.0-4C27.
cseg
public _move_
; move(count, s, d) /* intrasegment move */
; SEGSIZE count; /* number of bytes to move */
; BYTE *s, *d; /* source, destination */
_move_:
mov bx,sp
mov cx,[bx+2] ; count
jcxz mve2 ; if nothing to move
mov si,[bx+4] ; source offset
mov di,[bx+6] ; destination offset
push ds
pop es
cmp si,di ; compare addresses
jz mve2 ; if null move
ja mve3 ; if (source > destination), no overlap
std ; move from end of region
add si,cx
add di,cx
dec si
dec di
shr cx,1
jnb mve1 ; move byte if necessary
movsb
mve1: dec si
dec di
repz movsw
cld
mve2: ret
mve3: shr cx,1 ; move from start of region
repz movsw
jnb mve4 ; move remaining byte
movsb
mve4: ret